package com.example.finalapplication;

import static androidx.constraintlayout.motion.utils.Oscillator.TAG;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class Calculation2 extends AppCompatActivity {
float two=0.0f,five=0.0f,eight=0.0f,zero=0.0f;
float Result=0.0f;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_calculation2);
        Intent intent9 =getIntent();

         String City = intent9.getStringExtra("City");
         String Two = intent9.getStringExtra("Two");
         String Five = intent9.getStringExtra("Five");
         String Eight = intent9.getStringExtra("Eight");
         String Zero = intent9.getStringExtra("Zero");
         ((TextView) findViewById(R.id.title2)).setText(City);
         two=Float.parseFloat(Two);
         five=Float.parseFloat(Five);
         eight=Float.parseFloat(Eight);
         zero=Float.parseFloat(Zero);


    }
  public void myClick(View btn) {
        EditText Money = findViewById(R.id.yuan_inp);
        String str = Money.getText().toString();

        if (str.length() == 0) {
            Toast.makeText(this, "请输入金额！", Toast.LENGTH_SHORT).show();
            return;
        } else {
            float i = Float.parseFloat(str);
            float r = 0.0f;
        }
        Log.i(TAG, "myClick:");
        if (btn.getId() == R.id.button2) {
            float i = Float.parseFloat(str);
            Result = i / two;
        } else if (btn.getId() == R.id.button3) {
            float i = Float.parseFloat(str);
            Result = i / five;

        } else if(btn.getId() == R.id.button4){
            float i = Float.parseFloat(str);
            Result = i / eight;
        }else{
             float i = Float.parseFloat(str);
            Result = i/zero;
        }

        ((TextView) findViewById(R.id.result)).setText("可以加" + Result+"升");
    }



}